package com.sz.common.base.dao;


import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Function: 分页数据
 * Author: hpeng.wang <br>
 * Date: 2016-11-01 14:11:00
 */
public class ParamData extends HashMap implements Map {

    private static final long serialVersionUID = 1L;

    Map map = null;


    public Pagination getPagination() {
        return (Pagination) this.get("page");
    }

    public void setPagination(Pagination pagination) {
        this.put("page", pagination);
    }

    public ParamData() {
        map = new HashMap();
    }

    @Override
    public Object get(Object key) {
        Object obj = null;
        if (map.get(key) instanceof Object[]) {
            Object[] arr = (Object[]) map.get(key);
            /*obj = request == null ? arr : (request.getParameter((String) key) == null ? arr :
                    arr[0]);*/
            obj = arr;
        } else {
            obj = map.get(key);
        }
        return obj;
    }

    public String getString(Object key) {
        return (String) get(key);
    }

    @SuppressWarnings("unchecked")
    @Override
    public Object put(Object key, Object value) {
        return map.put(key, value);
    }

    @Override
    public Object remove(Object key) {
        return map.remove(key);
    }

    @Override
    public void clear() {
        map.clear();
    }

    @Override
    public boolean containsKey(Object key) {
        return map.containsKey(key);
    }

    @Override
    public boolean containsValue(Object value) {
        return map.containsValue(value);
    }

    @Override
    public Set entrySet() {
        return map.entrySet();
    }

    @Override
    public boolean isEmpty() {
        return map.isEmpty();
    }

    @Override
    public Set keySet() {
        return map.keySet();
    }

    @Override
    public void putAll(Map map) {
        this.map.putAll(map);
    }

    @Override
    public int size() {
        return map.size();
    }

    @Override
    public Collection values() {
        return map.values();
    }

}
